package com.enation.app.shop.front.policyInsurance.service.impl;

import com.enation.app.shop.front.policyInsurance.entity.InsuranceArea;
import com.enation.app.shop.front.policyInsurance.service.InsuranceAreaMapper;
import com.enation.framework.database.IDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("insuranceAreaService")
public class InsuranceAreaService implements InsuranceAreaMapper {
    @Autowired
    private IDaoSupport daoSupport;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insert(InsuranceArea record) {
        this.daoSupport.insert("rbt_insurance_area",record);
        return 1;
    }

    @Override
    public int insertSelective(InsuranceArea record) {
        return 0;
    }

    @Override
    public InsuranceArea selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(InsuranceArea record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(InsuranceArea record) {
        return 0;
    }

    @Override
    public List<InsuranceArea> getAll() {
        String sql="select * from  rbt_insurance_area ";
        return this.daoSupport.queryForList(sql,InsuranceArea.class);
    }

    @Override
    public List<InsuranceArea> getByPage(Integer page, Integer limit,String seacher) {
        if (seacher==null){
            String sql="select * from  rbt_insurance_area limit ?,?";
            return this.daoSupport.queryForList(sql,InsuranceArea.class,page,limit);
        }else {
            String sql="select * from  rbt_insurance_area  where insurance_staff_name like '%"+seacher+"%' limit ?,?";
            return this.daoSupport.queryForList(sql,InsuranceArea.class,page,limit);
        }

    }

    @Override
    public List<InsuranceArea> getBySercher(String seacher) {

        String sql="select * from  rbt_insurance_area where insurance_staff_name like '%"+seacher+"%'";
        return this.daoSupport.queryForList(sql,InsuranceArea.class);
    }
}
